﻿using System;
using HBase.cache;

namespace HBase
{
    public class BaseResult : BaseResultAbs
    {
        public object data { get; set; }
        public string Message { get; set; }
        public string ip { get; set; }
        public DateTime dt { get; set; }
        public int code { get; set; }
        public string msg { get; set; }
        public BaseResult(int c, string message, string data)
        {
            dt = DateTime.Now;
            code = c;
            Message = message;
            this.data = data;
            ip = BaseConfig.MeIp;
        }
        public BaseResult(object data)
        {
            dt = DateTime.Now;
            code = 200;
            Message = "";
            ip = BaseConfig.MeIp;
            this.data = data;
        }
        public static BaseResult Error(string message = "操作失败！", int code = 500)
        {
            BaseResult r = new BaseResult();
            r.code = code;
            r.msg = message;
            return r;
        }
        public static BaseResult Ok(object data)
        {
            BaseResult r = new BaseResult();
            r.code = 200;
            r.data = data;
            return r;
        }
        public BaseResult()
        {
            code = 200;
            ip = BaseConfig.MeIp;
            dt = DateTime.Now;
        }
    }
}
